// Copyright (c) 2023 CHANGLEI. All rights reserved.

library binding;

import 'dart:async';
import 'dart:ui' as ui;

// ignore: depend_on_referenced_packages
import 'package:fake_async/fake_async.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';

part 'package:flutter_grasp/src/service/default_binary_messenger.dart';

/// Created by changlei on 2021/9/13.
///
/// Interface for classes that register with the Widgets layer binding.
base mixin GraspFlutterBinding on WidgetsFlutterBinding {
  @override
  void initInstances() {
    super.initInstances();
    _instance = this;
  }

  /// The current [WidgetsBinding], if one has been created.
  ///
  /// Provides access to the features exposed by this mixin. The binding must
  /// be initialized before using this getter; this is typically done by calling
  /// [runGraspApp] or [GraspFlutterBinding.ensureInitialized].
  static GraspFlutterBinding get instance => BindingBase.checkInstance(_instance);
  static GraspFlutterBinding? _instance;

  @override
  @protected
  BinaryMessenger createBinaryMessenger() {
    return _DefaultBinaryMessenger._(super.createBinaryMessenger());
  }
}
